<template>
  <!-- 通知通告统计页面 -->
  <div>
    <div class='dialogTitle'>车厂未读列表</div>
    <!-- table -->
    <FilterTable
      height="300"
      ref="oemNoReadTable"
      :columns="oemNoReadColumns"
      :fetchapi="fetchapi"
      :params="oemNoReadParams"
      :isSelectColumn="isSelectColumn"
      :datakey="'records'"
      :onColumnsChange="oemNoReadColumns => this.oemNoReadColumns = oemNoReadColumns"
        columnsRef="notification_statistics_noReadFeedback_01"
    >

      <template slot="controls">
        <el-button size="small" type="primary" icon="el-icon-download" @click="downOemNoRead" :loading="saveLoading">下载</el-button>
      </template>
    </FilterTable>

    <div class='dialogTitle'>经销商未读列表</div>
    <!-- table -->
    <FilterTable
      height="300"
      ref="dealerNoReadTable"
      :columns="dealerNoReadColumns"
      :fetchapi="fetchapi"
      :params="dealerNoReadParams"
      :isSelectColumn="isSelectColumn"
      :datakey="'records'"
      :onColumnsChange= "dealerNoReadColumns => this.dealerNoReadColumns = dealerNoReadColumns"
      columnsRef="notification_statistics_noReadFeedback_02"

    >
      <template slot="controls">
        <el-button size="small" type="primary" icon="el-icon-download" @click="downDealerRead" :loading="saveLoading">下载</el-button>
      </template>
    </FilterTable>

    <div class="dialogBottmView">
      <el-button @click="closeDialog()">关 闭</el-button>
    </div>

  </div>
</template>

<script>
import { pageNotificationFeedback ,exportNotificationFeedback } from '@/api/cms-api/notification/statistics/index';
import { dictionary } from '@/utils/dictMixin';
import { exportExcelFile } from '@/utils';
import { region } from '@/api/cms-common/region';

export default {
  mixins: [dictionary, region],
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      oemNoReadColumns:this.createOemReadColumns(),
      oemReadList:null,
      dealerNoReadColumns:this.createDealerReadColumns(),
      dealerReadList:null,
      isSelectColumn:false,
      oemNoReadParams:{
        notificationId:this.value.notificationId,
        type:3,
        isDealer :0, // 不是
        status :15631002 // 未读
      },
      dealerNoReadParams:{
        notificationId:this.value.notificationId,
        type:4,
        isDealer :1, // 不是
        status :15631002 // 未读
      },
      fetchapi:pageNotificationFeedback,
      saveLoading: false
    };
  },
  methods: {
    createOemReadColumns(){
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },

        { title: '用户名', dataIndex: 'feedbackUserName', sorter: true },
      ];
    },
    createDealerReadColumns(){
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        //  {title: '区域', dataIndex: 'quyu',sorter:true},
				//  { title: '省份', dataIndex: 'provinceName', sorter: true,
				// 		render: props => {
				// 		 return <span>{this.createRegionText(props.row.PROVINCE_ID)}</span>;
				// 		}
				// 	},
        { title: '省份', dataIndex: 'provinceName', sorter: true },
          {title:'城市', dataIndex: 'cityName',sorter:true},
        { title: '公司代码', dataIndex: 'ownerCode', sorter: true },
        { title: '公司名称', dataIndex: 'dealerName', sorter: true },
        { title: '岗位', dataIndex: 'stationName', sorter: true },
         { title: '员工姓名', dataIndex: 'feedbackUserName', sorter: true },
        
         // { title: '事业部', dataIndex: 'deptName', sorter: true },
         //  { title: '办事处', dataIndex: 'officeName', sorter: true },

      ];
    },
    async downOemNoRead(){
      this.saveLoading = true;
      await exportNotificationFeedback(this.oemNoReadParams).then(res=>{this.saveLoading = false;exportExcelFile(res.data,"车厂未读列表")});
    },
    async downDealerRead(){
      this.saveLoading = true;
      await exportNotificationFeedback(this.dealerNoReadParams).then(res=>{this.saveLoading = false;exportExcelFile(res.data,"经销商未读列表")});
    },
    // 关闭当前页面操作
    closeDialog(type){
      this.$emit('close', { visible: false ,type:type});
    },
  }
};
</script>
<style lang="less" scoped>
</style>
